#!/bin/sh
#
#   http://code.google.com/media-translate/
#   Copyright (C) 2010  Serge A. Timchenko
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program. If not, see <http://www.gnu.org/licenses/>.
#

local DATAPATH=$BASEPATH/app/moskvafm
cd $DATAPATH

local CHANNELFILE=$TMPFILE.channel

get_opt "File"
local FILE="$opt"

[ -z "$FILE" ] && return 0

if ! expr "$FILE" : '/.*' > /dev/null; then
  FILE="$BASEPATH/$FILE"
fi

local COLUMNCOUNT="columnCount=5"
local STARTITEM="  startitem = \"middle\";"

if [ -x "$XSLTPROC" ]; then
  $XSLTPROC ../collection/channel.xslt "$FILE" | sed '1d' > $CHANNELFILE
else
  /usr/local/etc/awk -f getxml.awk -f ../collection/channel.awk "$FILE" > $CHANNELFILE
fi

(
  export CHANNELFILE; 
  export COLUMNCOUNT; 
  export STARTITEM;
  template2rss stations.xml  | printContent "application/rss+xml"
  rm -f $CHANNELFILE
)
